<template>
  <div class="right-board">
    <el-tabs v-model="currentTab" class="center-tabs">
      <el-tab-pane label="属性配置" name="field" />
    </el-tabs>
    <div class="field-box">
      <el-scrollbar class="right-scrollbar">
        <el-form size="small" label-width="100px" >
          <div v-for="(item,index) in cmps" :key="index">
            <component v-if="item.name === activeItem.compType" :formConf="formConf"  :getFormId="getFormId" :props="activeItem" :is="item.content"></component>
          </div>
        </el-form>
      </el-scrollbar>
    </div>
  </div>
</template>

<script>
import reg from "./custom/register";

export default {
  name:'configPanel',
  data() {
    return {
      currentTab: 'field',
      cmps:reg,
      formIdArray:[]
    }
  },
  props:{
    activeItem: {
      type: Object,
      default:function(){
        return {}
      }
    },
    itemList: {
      type: Array,
      default:function(){
        return []
      }
    },
    formConf: {
      type: Object,
    }
  },
  created() {
    this.cmps.forEach(c => {
      c.content = require(`./custom/configs/${c.name}`).default;
    });
  },
  methods:{
    getFormId(itemId){
      this.formIdArray = [];
      Array.from(this.itemList,(item)=>{
        if(item.compType === 'row'){
          Array.from(item.columns,(column)=>{
            Array.from(column.list,(col)=>{
              if(col._id !== itemId){
                this.formIdArray.push(col.id);
              }
            })
          })
        }else{
          if(item._id !== itemId){
            this.formIdArray.push(item.id);
          }
        }
      })
      return this.formIdArray;
    }
  }
}
</script>
<style scoped>
.right-board {
  height: 100%;
  width: 350px;
  position: relative;
  right: 0;
  top: 0;
  padding-top: 3px;
  .field-box {
    position: relative;
    height: calc(100% - 42px);
    box-sizing: border-box;
    overflow: hidden;
  }
  .right-scrollbar {
    height: 100%;
  }
}
::v-deep .select-item {
  display: flex;
  border: 1px dashed #fff;
  box-sizing: border-box;
  & .close-btn {
    cursor: pointer;
    color: #f56c6c;
  }
  & .el-input + .el-input {
    margin-left: 4px;
  }
}
::v-deep .select-item + .select-item {
  margin-top: 4px;
}
::v-deep .select-item.sortable-chosen {
  border: 1px dashed #409eff;
}
::v-deep .select-line-icon {
  line-height: 32px;
  font-size: 22px;
  padding: 0 4px;
  color: #777;
}
::v-deep .option-drag {
  cursor: move;
}
::v-deep .time-range {
  .el-date-editor {
    width: 227px;
  }
  ::v-deep .el-icon-time {
    display: none;
  }
}
::v-deep .document-link {
  position: absolute;
  display: block;
  width: 26px;
  height: 26px;
  top: 0;
  left: 0;
  cursor: pointer;
  background: #409eff;
  z-index: 1;
  border-radius: 0 0 6px 0;
  text-align: center;
  line-height: 26px;
  color: #fff;
  font-size: 18px;
}
::v-deep .node-label{
  font-size: 14px;
}
::v-deep .node-icon{
  color: #bebfc3;
}
::v-deep .center-tabs{
  .el-tabs__header{
    margin-bottom: 0!important;
  }
  .el-tabs__item{
    width: 100%;
    text-align: center;
  }
  .el-tabs__nav{
    width: 100%;
  }
}
::v-deep .right-scrollbar {
  .el-scrollbar__view {
    padding: 12px 18px 15px 15px;
  }
}
.field-box ::v-deep .el-scrollbar__wrap{
  overflow-x: hidden;
}
::v-deep .components-item.dynamicGhost {
  width: 5px;
  height: 120px;
  background-color: #409EFF;
}
::v-deep .dynamic-table_item.dynamicGhost {
  width: 5px;
  height: 120px;
  background-color: #409EFF;
}

</style>
